package com.xyw.code.gateway.admin.event;

import com.xyw.code.gateway.admin.config.BusConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.amqp.support.converter.MessageConverter;

import javax.annotation.PostConstruct;


/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/2/5
 * Time: 下午1:24
 * Email: 1328312923@qq.com
 * Description: mq消息发送
 **/
@Component
@Slf4j
public class EventSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String routingKey,String message){
        log.info("routeKey:{}=>message:{}",routingKey,message);
        rabbitTemplate.convertAndSend(BusConfig.EXCHANGE_NAME, routingKey, message);
    }
}
